import { getViewer } from "yt-cesium";
import { Viewer } from "cesium";

const resolvedPromise = Promise.resolve() as Promise<any>;

/**
 * 将任务添加到微任务队列
 * @param fn
 */
export function nextTick(fn?: (viewer: Viewer) => void | PromiseLike<void>) {
  return fn
    ? resolvedPromise.then(() => fn.call(null, getViewer()))
    : resolvedPromise.then(() => getViewer());
}
